﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;

namespace Microsoft.Rtc.Collaboration.Samples.HTMLPresenceControls.Controls.Configuration
{
    /// <summary>
    /// Properties
    /// </summary>
    public class PresenceService : ConfigurationElement
    {
        /// <summary>
        /// Full URL of the WCF sevice to query. Should include querystring and/or sip: prefix
        /// </summary>
        [ConfigurationProperty("Url", IsRequired = true)]
        [StringValidator(InvalidCharacters = "~!@#$%^&*()[]{};'\"|")]
        public String Url
        {
            get
            {
                return (String)this["Url"];
            }
            set
            {
                this["Url"] = value;
            }
        }

        /// <summary>
        /// Amount of time (seconds) that will elapse before the subsequent request.
        /// </summary>
        [ConfigurationProperty("RefreshInterval", IsRequired = false, DefaultValue = 3)]
        [IntegerValidator(ExcludeRange = false, MinValue = 3, MaxValue = 60)]
        public int RefreshInterval
        {
            get
            {
                try
                {
                    return (int)this["RefreshInterval"];
                }
                catch (ConfigurationErrorsException cee) { throw cee; }
                catch (ConfigurationException ce) { throw ce; }
                catch (Exception ex) { throw ex; }
            }
            set
            {
                this["RefreshInterval"] = value;
            }
        }
    }
}
